<include file="Public/header"/>	 
<body>
<div class="tab_nav tab_nav_none">
    <div class="header">
	<a href="javascript:void(0);" onClick="javascript:history.go(-1);" class="header_l"><i class="fa fa-angle-left"></i></a>
      <div class="h-mid">申请售后   </div>
	<a href="{:U('Index/index')}" class="header_r"><i class="fa fa-home"></i></a>
	  
    </div>
</div>

<include file="Public/menu"/>

<include file="Public/menu"/>
	<form name="return_form" id="return_form" autocomplete="off" method="post" enctype="multipart/form-data" >
		<div class="main_sq">
			<div class="touchweb-com_searchListBox" id="goods_list">
		   		<li>
	                <a href="{:U('Mobile/Goods/goodsInfo',array('id'=>$goods['goods_id']))}" class="item">
						<div class="pic_box">
	                        <img title="{$goods['goods_name']}" src="{$goods[goods_id]|goods_thum_images=400,400}" />
						</div>
						<div class="title_box">{$goods['goods_name']}</div>
					</a>
			    </li>
			</div>
		<div class="T_H">
			<div class="retu_sq"><a id="retu_a_sq" class="orange_sq">退貨</a><input type="radio" style="display:;" checked="" value="0" name="type"></div>
			<div class="chan_sq"><a id="chec_a_sq">換貨</a><input type="radio" style="display:;" value="1" name="type"></div>
		</div>
		<div class="ques_sq">
			<div class="ques_desc_sq">
				<span>問題描述：</span>
				<div class="textarea_sq">
	                <textarea name="reason" id="reason"></textarea>
				</div>
			</div>
		</div>	
		<div class="file_up_sq">
			<div class="file_sq">
				<div> 
					<div class="p_main">
                        <h2>上傳圖片：</h2>
                        <a class="file" href="javascript:;"><div style="width:60px;height:60px;" id="fileList0"><img width="60" height="60" ></div><input type="file" accept="image/*" name="return_imgs[]" onChange="handleFiles(this,0)"></a>
                        <a class="file" href="javascript:;"><div style="width:60px;height:60px;" id="fileList1"><img width="60" height="60"></div><input type="file" accept="image/*" name="return_imgs[]" onChange="handleFiles(this,1)"></a>
                        <a class="file" href="javascript:;"><div style="width:60px;height:60px;" id="fileList2"><img width="60" height="60"></div><input type="file" accept="image/*" name="return_imgs[]" onChange="handleFiles(this,2)"></a>
                        <a class="file" href="javascript:;"><div style="width:60px;height:60px;" id="fileList3"><img width="60" height="60"></div><input type="file" accept="image/*" name="return_imgs[]" onChange="handleFiles(this,3)"></a>
                        <span style=" font-size:14px; display:block; width:100%; overflow:hidden">
                    </div>
				</div>
			</div>
		</div>
		<div class="send sq">
			<div class="sendssq">
				<ul>
					<li>寄回地址：{$tpshop_config['shop_info_address']}</li>
					<li>上班時間：（周壹至周五）08：00-19:00（周六日休息）</li>
					<li>客服電話：{$tpshop_config['shop_info_phone']}</li>
				</ul>
			</div>
		</div>
		<div class="submit_sq">
	        <a href="javascript:void(0)" onClick="submit_form();" name="btnSubmit"><s></s>提交</a>
		</div>
	</div>
      <input type="hidden" name="order_id" value="{$order_id}" />
      <input type="hidden" name="order_sn" value="{$order_sn}" />
      <input type="hidden" name="goods_id" value="{$goods_id}" />
      <input type="hidden" name="spec_key" value="{$_GET[spec_key]}" />
 </form>    
 
<script type="text/javascript">

  function submit_form()
  {

	  var reason = $.trim($('#reason').val());
	  var return_imgs= $.trim($('#return_imgs').val());
	  if(reason == '')
	  {
		  alert('請輸入退換貨原因');// alert('請輸入退換貨原因!');
		  return false;
	  }

	  var ff = document.getElementsByName("return_imgs[]");

	  if((ff[0].value.length + ff[1].value.length + ff[2].value.length + ff[3].value.length) == 0)
	  {
		  if(!confirm('確定不傳照片嗎?'))
		  {
			  return false;
		  }
      }
	  $('#return_form').submit();
  } 
   
   //  退換貨顏色切換
	$(document).ready(function(){
			//$('#retu_a_sq').addClass('orange_sq');
			$('#retu_a_sq').click(function(){
				if ($(this).hasClass('orange_sq')) {
					$('#chec_a_sq').removeClass('orange_sq');
				} else{
					$(this).addClass('orange_sq');
					$(this).siblings('input').trigger('click');
					$('#chec_a_sq').removeClass('orange_sq');
				}
			});
			$('#chec_a_sq').click(function(){
				if ($(this).hasClass('orange_sq')) {
					$('#retu_a_sq').removeClass('orange_sq');
				} else{
					$(this).addClass('orange_sq');
					$(this).siblings('input').trigger('click');						
					$('#retu_a_sq').removeClass('orange_sq');
				}
			})

	})
	
window.URL = window.URL || window.webkitURL;
function handleFiles(obj,id) {
	fileList = document.getElementById("fileList"+id);
		var files = obj.files;
		img = new Image();
		if(window.URL){	
			
			img.src = window.URL.createObjectURL(files[0]); //創建壹個object URL，並不是妳的本地路徑
			img.width = 60;
	    	img.height = 60;
			img.onload = function(e) {
				window.URL.revokeObjectURL(this.src); //圖片加載後，釋放object URL
			}
		    if(fileList.firstElementChild){
		         fileList.removeChild(fileList.firstElementChild);
		    } 
			fileList.appendChild(img);
		}else if(window.FileReader){
			//opera不支持createObjectURL/revokeObjectURL方法。我們用FileReader對象來處理
			var reader = new FileReader();
			reader.readAsDataURL(files[0]);
			reader.onload = function(e){	
		            img.src = this.result;
		            img.width = 60;
		            img.height = 60;
		            fileList.appendChild(img);
			}
	    }else
	    {
			//ie
			obj.select();
			obj.blur();
			var nfile = document.selection.createRange().text;
			document.selection.empty();
			img.src = nfile;
			img.width = 60;
		    img.height = 60;
			img.onload=function(){
			  
		    }
			fileList.appendChild(img);
	    }
}
	
</script>
<include file="Public/footer_nav"/>
</body>
</html>